﻿<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:Rio_Framework_Pages_Controls="clr-namespace:Rio.Framework.Pages.Controls;assembly=Rio.Framework.Pages"
             xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
             xmlns:mvvmLightCommand="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.SL4"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             x:Class="Rio.Manager.Application.Views.ConnectorTabView"
             mc:Ignorable="d"
             d:DesignHeight="768"
             d:DesignWidth="1024">

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../../Skins/ConnectorTabSkin.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>

    <UserControl.DataContext>
        <Binding Path="ConnectorTab"
                 Source="{StaticResource Locator}" />
    </UserControl.DataContext>

    <Grid x:Name="LayoutRoot">
        <i:Interaction.Triggers>
            <i:EventTrigger EventName="Loaded">
                <mvvmLightCommand:EventToCommand Command="{Binding InitializationCommand}" />
            </i:EventTrigger>
        </i:Interaction.Triggers>

        <!--General grid definition-->
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition/>
        </Grid.RowDefinitions>
        
        <!--View title-->
        <TextBlock TextWrapping="Wrap"
                   Text="{Binding ConnectorTitleList}"
                   FontWeight="Bold"
                   Margin="10,10,0,10"/>

        <!--View informations--> 
        <Grid Margin="20,0,20,20" 
              Grid.Row="2">
            
            <!--Grid information definition.-->
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            
            <!--Button toolbar.-->
            <telerik:RadToolBar>
                <!--Add button toolbar-->
                <telerik:RadMenuItem Command="{Binding ConnectorCommandCreate}">
                    <telerik:RadMenuItem.Header>
                        <StackPanel Orientation="Horizontal">
                            <Image Source="/Rio.Manager.Application;component/Assets/Images/Connector_Add.png"
                                   Width="22"
                                   Height="22" />
                            <TextBlock TextWrapping="Wrap"
                                       VerticalAlignment="Center"
                                       Text="{Binding NewConnector}"
                                       Margin="5,0,0,0" />
                        </StackPanel>
                    </telerik:RadMenuItem.Header>
                </telerik:RadMenuItem>

                <!--Update button toolbar-->
                <telerik:RadMenuItem Command="{Binding ConnectorCommandModify}"
                                     IsEnabled="{Binding CanUpdateConnector, Mode=TwoWay}">
                    <telerik:RadMenuItem.Header>
                        <StackPanel Orientation="Horizontal">
                            <Image Source="/Rio.Manager.Application;component/Assets/Images/Connector_Update.png"
                                   Width="22"
                                   Height="22" />
                            <TextBlock TextWrapping="Wrap"
                                       VerticalAlignment="Center"
                                       Text="{Binding ModifyConnector}"
                                       Margin="5,0,0,0" />
                        </StackPanel>
                    </telerik:RadMenuItem.Header>
                </telerik:RadMenuItem>

                <!--Delete button toolbar-->
                <telerik:RadMenuItem Command="{Binding ConnectorCommandDelete}"
                                     IsEnabled="{Binding CanDeleteConnector, Mode=TwoWay}">                    
                    <telerik:RadMenuItem.Header>
                        <StackPanel Orientation="Horizontal">
                            <Image Source="/Rio.Manager.Application;component/Assets/Images/Connector_Delete.png"
                                   Width="22"
                                   Height="22" />
                            <TextBlock TextWrapping="Wrap"
                                       VerticalAlignment="Center"
                                       Text="{Binding DeleteConnector}"
                                       Margin="5,0,0,0" />
                        </StackPanel>
                    </telerik:RadMenuItem.Header>
                </telerik:RadMenuItem>

                <!--Refresh button toolbar-->
                <telerik:RadMenuItem Command="{Binding ConnectorCommandRefresh}">
                    <telerik:RadMenuItem.Header>
                        <StackPanel Orientation="Horizontal">
                            <Image Source="/Rio.Manager.Application;component/Assets/Images/Connector_Refresh.png"
                                   Width="22"
                                   Height="22" />
                            <TextBlock TextWrapping="Wrap"
                                       VerticalAlignment="Center"
                                       Text="{Binding RefreshConnector}"
                                       Margin="5,0,0,0" />
                        </StackPanel>
                    </telerik:RadMenuItem.Header>
                </telerik:RadMenuItem>
            </telerik:RadToolBar>

            <!--Show connector informations-->
            <!--Grid definition.-->
            <telerik:RadGridView x:Name="RadGridView_Connector_Information"
                                 Grid.Row="1"
                                 ShowGroupPanel="False" 
                                 IsFilteringAllowed="True"
                                 ItemsSource="{Binding ConnectorInformationList, Mode=TwoWay}"
                                 RowIndicatorVisibility="Collapsed"
                                 IsReadOnly="True"
                                 AutoGenerateColumns="False"
                                 CanUserFreezeColumns="False"
                                 CanUserResizeColumns="False"
                                 SelectionMode="Extended"
                                 SelectionChanged="RadGridView_Connector_Information_SelectionChanged">

                <!--Context Menu-->
                <!--<telerik:RadContextMenu.ContextMenu>
                    <telerik:RadContextMenu Name="ContextMenu_Connector_Information" 
                                            Visibility="Collapsed"
                                            Opened="ContextMenu_Connector_Information_Opened">-->
                        <!--Menu Add-->
                        <!--<telerik:RadMenuItem Name="ConnectorMenuAdd"
                                             Header ="{Binding NewConnector}"
                                             IsEnabled="{Binding CanAddConnector, Mode=TwoWay}"
                                             Command="{Binding ConnectorCommandCreate}">
                            <telerik:RadMenuItem.Icon>
                                <Image Source="/Rio.Manager.Application;component/Assets/Images/Connector_Add.png"
                                       Height="16"
                                       Width="16"/>
                            </telerik:RadMenuItem.Icon>
                        </telerik:RadMenuItem>-->
                        
                        <!--Menu Update-->
                        <!--<telerik:RadMenuItem Name="ConnectorMenuUpdate"
                                             Header ="{Binding ModifyConnector}"
                                             IsEnabled="{Binding CanUpdateConnector, Mode=TwoWay}"
                                             Command="{Binding ConnectorCommandModify}">
                            <telerik:RadMenuItem.Icon>
                                <Image Source="/Rio.Manager.Application;component/Assets/Images/Connector_Update.png"
                                       Height="16"
                                       Width="16"/>
                            </telerik:RadMenuItem.Icon>
                        </telerik:RadMenuItem>-->

                        <!--Menu Delete-->
                        <!--<telerik:RadMenuItem Name="ConnectorMenuDelete"
                                             Header ="{Binding DeleteConnector}"
                                             IsEnabled="{Binding CanDeleteConnector, Mode=TwoWay}"
                                             Command="{Binding ConnectorCommandDelete}">
                            <telerik:RadMenuItem.Icon>
                                <Image Source="/Rio.Manager.Application;component/Assets/Images/Connector_Delete.png"
                                       Height="16"
                                       Width="16"/>
                            </telerik:RadMenuItem.Icon>
                        </telerik:RadMenuItem>-->

                        <!--Menu Refresh-->
                        <!--<telerik:RadMenuItem Name="ConnectorMenuRefresh"
                                             Header ="{Binding RefreshConnector}"
                                             IsEnabled="{Binding CanRefreshConnector, Mode=TwoWay}"
                                             Command="{Binding ConnectorCommandRefresh}">
                            <telerik:RadMenuItem.Icon>
                                <Image Source="/Rio.Manager.Application;component/Assets/Images/Connector_Refresh.png"
                                       Height="16"
                                       Width="16"/>
                            </telerik:RadMenuItem.Icon>
                        </telerik:RadMenuItem>
                    </telerik:RadContextMenu>
                </telerik:RadContextMenu.ContextMenu>-->
                
                <!--General informations connector.-->
                <telerik:RadGridView.Columns>
                    <telerik:GridViewSelectColumn/>
                    <telerik:GridViewToggleRowDetailsColumn/>
                    <telerik:GridViewDataColumn Header="{Binding ConnectorTab.HeaderConnectorName, Source={StaticResource Locator}, Mode=OneWay}"
                                                DataMemberBinding="{Binding ConnectorName}"/>
                    <telerik:GridViewDataColumn Header="{Binding ConnectorTab.HeaderConnectorDescription, Source={StaticResource Locator}, Mode=OneWay}"
                                                DataMemberBinding="{Binding ConnectorDescription}"/>
                    <telerik:GridViewDataColumn Header="{Binding ConnectorTab.HeaderConnectorOrganization, Source={StaticResource Locator}, Mode=OneWay}"
                                                DataMemberBinding="{Binding OrganizationName}"/>
                    <telerik:GridViewDataColumn Header="{Binding ConnectorTab.HeaderConnectorFolderTypeName, Source={StaticResource Locator}, Mode=OneWay}"
                                                DataMemberBinding="{Binding FolderTypeName}"/>                   
                </telerik:RadGridView.Columns>
               
                <!--Connector details: 
                           - Show correspondence details
                           - Show parameters details-->
                                
                <telerik:RadGridView.RowDetailsTemplate>
                    <DataTemplate>
                        
                        <!--RadTabControl definition-->
                        <telerik:RadTabControl x:Name="RadTabControl_Connector_Information"
                                               BackgroundVisibility="Collapsed"
                                               Background="Transparent"
                                               Margin="0,10,0,10">                                               
                                                                           
                            <!--Correspopndence details-->
                            <telerik:RadTabItem Header="{Binding ConnectorTab.RadTabItemHeaderConnectorCorrespondence, Source={StaticResource Locator}, Mode=OneWay}">
                                <StackPanel Orientation="Vertical">
                                    <!--Item correspondence title-->
                                    <TextBlock TextWrapping="Wrap"
                                               Text="{Binding ConnectorTab.ConnectorCorrespondencesItemList, Source={StaticResource Locator}, Mode=OneWay}"
                                               FontWeight="Bold"
                                               Margin="10,10,0,10" />
                                    <!--Grid View to show correspondence connector.-->
                                    <telerik:RadGridView x:Name="RadGridView_Connector_Information_Correspondence"
                                                         ShowGroupPanel="False"
                                                         IsFilteringAllowed="True"
                                                         IsReadOnly="True"
                                                         ItemsSource="{Binding LstConnectorCorrespondence, Mode=TwoWay}"
                                                         AutoGenerateColumns="False"
                                                         CanUserFreezeColumns="False"
                                                         CanUserResizeColumns="False">
                                        <!--Correspondence informations connector.-->
                                        <telerik:RadGridView.Columns>
                                            <telerik:GridViewDataColumn Header="{Binding ConnectorTab.HeaderCorrespondenceIndexName, Source={StaticResource Locator}, Mode=OneWay}"
                                                                        DataMemberBinding="{Binding ConnectorIndexCorrespondenceName}"/>
                                            <telerik:GridViewDataColumn Header="{Binding ConnectorTab.HeaderCorrespondenceIndexPosition, Source={StaticResource Locator}, Mode=OneWay}"
                                                                        DataMemberBinding="{Binding ConnectorIndexCorrespondencePosition}"/>
                                            <telerik:GridViewDataColumn Header="{Binding ConnectorTab.HeaderCorrespondenceIndexDescription, Source={StaticResource Locator}, Mode=OneWay}"
                                                                        DataMemberBinding="{Binding ConnectorIndexCorrespondenceDescription}"/>                                       
                                        </telerik:RadGridView.Columns>
                                    </telerik:RadGridView>
                                </StackPanel>
                            </telerik:RadTabItem>

                            <!--Parameters details-->
                            <telerik:RadTabItem Header="{Binding ConnectorTab.RadTabItemHeaderConnectorParameters, Source={StaticResource Locator}, Mode=OneWay}">
                                <StackPanel Orientation="Vertical">
                                    <!--Item parameters title-->
                                    <TextBlock TextWrapping="Wrap"
                                               Text="{Binding ConnectorTab.ConnectorParametersItemList, Source={StaticResource Locator}, Mode=OneWay}"
                                               FontWeight="Bold"
                                               Margin="10,10,0,10" />
                                    <!--Grid View to show parameters connector.-->
                                    <telerik:RadGridView x:Name="RadGridView_Connector_Information_Parameters"
                                                         ShowGroupPanel="False"
                                                         IsFilteringAllowed="True"
                                                         IsReadOnly="True"
                                                         ItemsSource="{Binding LstConnectorParameters, Mode=TwoWay}"
                                                         AutoGenerateColumns="False"
                                                         CanUserFreezeColumns="False"
                                                         CanUserResizeColumns="False">
                                        <!--Parameters informations connector.-->
                                        <telerik:RadGridView.Columns>
                                            <telerik:GridViewDataColumn Header="{Binding ConnectorTab.HeaderParametersERP, Source={StaticResource Locator}, Mode=OneWay}"
                                                                        DataMemberBinding="{Binding ConnectorCustomerParam}"/>
                                            <telerik:GridViewDataColumn Header="{Binding ConnectorTab.HeaderParametersRIO, Source={StaticResource Locator}, Mode=OneWay}"
                                                                        DataMemberBinding="{Binding ConnectorRioParam}"/>
                                            <telerik:GridViewDataColumn Header="{Binding ConnectorTab.HeaderParametersDescription, Source={StaticResource Locator}, Mode=OneWay}"
                                                                        DataMemberBinding="{Binding ConnectorDescriptionParam}"/>
                                        </telerik:RadGridView.Columns>
                                    </telerik:RadGridView>
                                </StackPanel> 
                            </telerik:RadTabItem>
                        </telerik:RadTabControl>
                    </DataTemplate>
                </telerik:RadGridView.RowDetailsTemplate>
            </telerik:RadGridView>
        </Grid>
        
        <telerik:RadBusyIndicator BusyContent=""
                                  IsBusy="{Binding BusyIndicator.IsBusy, Mode=OneWay}"
                                  Grid.RowSpan="2"
                                  d:IsHidden="True"/>
    </Grid>
</UserControl>
